<?php
//迭代类
class AllUser implements \Iterator {
	protected $ids;
	protected $index;
	protected $data = [];
	//连接数据库
	function __construct () {
		$db = Factory::getDatabase();
		$result = $db->query('select * from user');
		$this->ids = $result->fetch_all(mysqli_assoc);	
	
	}
	
	//获取信息
	function current () {
		$id = $this->ids[$this->index]['id'];
		return Factory::getUser($id)
	}
	
	//获取获取下一个
	function next () {
		$this->index++;
	}
	
	//验证方法
	function valid () {
		return $this->index < count($this->ids);
	}

	//初始化
	function rewind() {
		$this->index = 0;
	}
	//获取键
	function key () {
		return $this->index;
	}
}
